import express from 'express';
import {uploadEquipmentImage,deleteEquipmentImage,getEquipmentImage} from '../../api/equipment-img.js';
// import { verifyToken } from '../middleware/auth.js';
import { verifyToken } from "../../utils/TokenCheck.js";

// 单独配置图片上传中间件
import multer from 'multer';
const upload = multer({ 
    limits: { fileSize: 5 * 1024 * 1024 },
  fileFilter: (req, file, cb) => {
    const allowedTypes = ['image/jpeg', 'image/png'];
    cb(null, allowedTypes.includes(file.mimetype));
  }
});

export default function equipmentImgRouter(router) {
// 上传/更新设备图片
router.post('/:equipmentId/image',verifyToken,upload.single('image'),uploadEquipmentImage);

// 获取设备图片URL
router.get('/:equipmentId/image', getEquipmentImage);

// 删除设备图片
router.delete('/:equipmentId/image', verifyToken, deleteEquipmentImage);
    
}
